quartz: disable system shadows if a GdkWindow shadow is set.
authorChristoph Reiter <reiter.christoph@gmail.com>
Sun, 19 Jul 2015 18:13:22 +0000 (20:13 +0200)
committerChristoph Reiter <creiter@src.gnome.org>
Mon, 27 Jul 2015 15:26:46 +0000 (17:26 +0200)
The shadow will be drawn in the wrong place in those cases so all we can
do is disable it. This fixes double shadows drawn around menus, popups
and tooltips.

https://bugzilla.gnome.org/show_bug.cgi?id=734984

gdk/quartz/gdkwindow-quartz.c
gdk/quartz/gdkwindow-quartz.h

index 7d6bfe4dad7f9f6c8596afc7b71b484a92b0c8d5..ff759d02e977f36c900e1771ade9380db701fab1 100644 (file)
@@ -2132,6 +2132,19 @@ window_type_hint_to_hides_on_deactivate (GdkWindowTypeHint hint)
   return FALSE;
 }
 
+static void
+_gdk_quartz_window_update_has_shadow (GdkWindowImplQuartz *impl)
+{
+    gboolean has_shadow;
+
+    /* In case there is any shadow set we have to turn off the
+     * NSWindow setHasShadow as the system drawn ones wont match our
+     * window boundary anymore */
+    has_shadow = (window_type_hint_to_shadow (impl->type_hint) && !impl->shadow_max);
+
+    [impl->toplevel setHasShadow: has_shadow];
+}
+
 static void
 gdk_quartz_window_set_type_hint (GdkWindow        *window,
                                  GdkWindowTypeHint hint)
@@ -2150,7 +2163,7 @@ gdk_quartz_window_set_type_hint (GdkWindow        *window,
   if (GDK_WINDOW_IS_MAPPED (window))
     return;
 
-  [impl->toplevel setHasShadow: window_type_hint_to_shadow (hint)];
+  _gdk_quartz_window_update_has_shadow (impl);
   [impl->toplevel setLevel: window_type_hint_to_level (hint)];
   [impl->toplevel setHidesOnDeactivate: window_type_hint_to_hides_on_deactivate (hint)];
 }
@@ -2393,7 +2406,8 @@ gdk_quartz_window_set_decorations (GdkWindow       *window,
                                                                   backing:NSBackingStoreBuffered
                                                                     defer:NO
                                                                    screen:screen];
-          [impl->toplevel setHasShadow: window_type_hint_to_shadow (impl->type_hint)];
+          _gdk_quartz_window_update_has_shadow (impl);
+
           [impl->toplevel setLevel: window_type_hint_to_level (impl->type_hint)];
           if (title)
             [impl->toplevel setTitle:title];
@@ -2825,6 +2839,8 @@ gdk_quartz_window_set_shadow_width (GdkWindow *window,
     return;
 
   impl->shadow_top = top;
+  impl->shadow_max = MAX (MAX (left, right), MAX (top, bottom));
+  _gdk_quartz_window_update_has_shadow (impl);
 }
 
 static cairo_region_t *
index ccd763369955925eb5261ef812f5238e4b845f75..4c8347c9e5f5c07920e8aafc328085b3756d58f4 100644 (file)
@@ -62,6 +62,8 @@ struct _GdkWindowImplQuartz
   cairo_surface_t *cairo_surface;
 
   gint shadow_top;
+
+  gint shadow_max;
 };
  
 struct _GdkWindowImplQuartzClass